package com.sservice.service.service.impl;

import com.sservice.model.dao.IOfferDao;
import com.sservice.model.dao.IOrderDao;
import com.sservice.model.dao.LadingOrderMapper;
import com.sservice.model.entity.LadingOrder;
import com.sservice.model.vo.LadingOrderVo;
import com.sservice.service.service.ILadingOrderService;
import com.sservice.base.entity.dto.ListResult;
import com.sservice.base.entity.dto.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;


/**
 * Created by suweiming on 2017/12/20.
 */

@Service
@Transactional
public class LadingOrderServiceImpl implements ILadingOrderService {
    @Autowired
    private LadingOrderMapper dataDao;
    @Autowired
    private IOrderDao orderDao;
    @Autowired
    private IOfferDao offerDao;


    @Override
    public int deleteByPrimaryKey(Integer id) {
        return dataDao.deleteByPrimaryKey(id);
    }

    @Override
    public int insert(LadingOrder record) {
        return dataDao.insert(record);
    }

    @Override
    public int insertSelective(LadingOrder record) {
        return dataDao.insertSelective(record);
    }

    @Override
    public LadingOrder selectByPrimaryKey(Integer id) {
        return dataDao.selectByPrimaryKey(id);
    }

    @Override
    public int updateByPrimaryKeySelective(LadingOrder record) {
        return dataDao.updateByPrimaryKeySelective(record);
    }

    @Override
    public int updateByPrimaryKey(LadingOrder record) {
        return dataDao.updateByPrimaryKey(record);
    }

    @Override
    public int addBatch(List<LadingOrder> list) {
        return dataDao.addBatch(list);
    }

    @Override
    public List<LadingOrder> selectByLadingId(String ladingId) {
        return dataDao.selectByLadingId(ladingId);
    }

    @Override
    public ListResult byPage(LadingOrderVo lov) {
        List<LadingOrderVo> lovList = dataDao.queryByPage(lov);
        int total = dataDao.queryByCount(lov);
        ListResult res = new ListResult(true, lovList);
        Pagination page = new Pagination(lov.getPage(), total, lov.getSize());
        res.setPage(page);
        return res;
    }

    @Override
    public List<LadingOrderVo> queryOrderBill(LadingOrder orderId) {
        return dataDao.queryOrderBill(orderId);
    }
}
